package com.hc.nong;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface NongMapper {
    @Update("update user1 set money=money-#{money}, transfer = transfer + #{money} where id =#{userId}")
    void reduceMoney(@Param("userId") int userId, @Param("money") double money);

    @Update("update user1 set transfer = transfer - #{money} where id = #{userId}")
    void commit(@Param("userId") int userId, @Param("money") double money);

    @Update("update user1 set transfer = transfer - #{money}, money=money + #{money} where id = #{userId}")
    void cancel(@Param("userId") int userId, @Param("money") double money);


    @Select("select money from user1 where id = #{userId}")
    Double findMoneyById(int userId);
}